<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib prefix="s" uri="/struts-tags" %>
<form action="<s:url action="ledger"/>" method="post" accept-charset="utf-8" id="filter_form">

<div id="report_date_range_simple">
		<input type="radio" checked="checked" value="simple" id="simple_radio" name="report_type">
		<select id="report_date_range_simple" name="report_date_range_simple">
<option value="2012-06-15/2012-06-15">Today</option>
<option value="2012-06-14/2012-06-14">Yesterday</option>
<option value="2012-06-09/2012-06-15">Last 7 Days</option>
<option value="2012-06-01/2012-06-30">This Month</option>
<option value="2012-05-01/2012-05-31">Last Month</option>
<option value="2012-01-01/2012-12-31">This Year</option>
<option value="2011-01-01/2011-12-31">Last Year</option>
<option value="1969-12-31/2012-06-15">All Time</option>
</select>	</div>
<div id="report_date_range_complex">
		<input type="radio" value="complex" id="complex_radio" name="report_type">
		<select id="start_month" name="start_month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option selected="selected" value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>		<select id="start_day" name="start_day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option selected="selected" value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>		<select id="start_year" name="start_year">
<option selected="selected" value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
</select>		-
		<select id="end_month" name="end_month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option selected="selected" value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select id="end_day" name="end_day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option selected="selected" value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select id="end_year" name="end_year">
<option selected="selected" value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
</select>	</div>
</form>
<table style="width: 100%;" id="contents">
<tr><td>${customer.name}</td></tr>
<tr><td>${customer.address}</td></tr>
<tr><td>${customer.city}</td></tr>
<tr><td>${customer.primaryCell}</td></tr>
</table>

<table style="width: 100%;" id="contents">
	<tbody><tr>
		<td id="item_table">
			<table id="suspended_sales_table">
				<tbody><tr>
					<th>ID#</th>
					<th>Type</th>
					<th>Date</th>
					<th>Comments</th>
					<th>Total Amount</th>
					<th>Payment</th>
					<th>Due Amount</th>
					<th>Employee</th>
					<th>Sales Receipt</th>

				</tr>
        <jsp:useBean id="dateValue" class="java.util.Date" />

<c:forEach var="item" items="${orderEntities}">
            <tr>
						<td>${item.id}</td>
						<td>Sale</td>
                         <jsp:setProperty name="dateValue" property="time" value="${item.orderDate}" />

						<td><fmt:formatDate pattern="dd/MM/yyyy hh:mm aaa"        value="${dateValue}" /></td>

						<td>${item.note}</td>
						<td>INR ${item.totalAmount}</td>
                        <td>INR ${item.totalAmount-item.dueAmount}</td>
						<td>INR ${item.dueAmount}</td>
						<td> ${item.employee.userName}</td>

						<td>
							<form id="form_receipt_suspended_sale" method="get" accept-charset="utf-8" action="${pageContext.request.contextPath}/receipts/orderreceipt.ps">
							<input type="hidden" value="${item.id}" name="id">
							<input type="submit" class="submit_button float_right" id="submit_receipt" value="Receipt" name="submit">
							</form>
						</td>

					</tr>
            </c:forEach>
            <c:forEach var="item" items="${paymentEntities}">
            <tr>
						<td>${item.id}</td>
						<td>Payment</td>
                         <jsp:setProperty name="dateValue" property="time" value="${item.paymentDate}" />

						<td><fmt:formatDate type="both"    dateStyle="short" timeStyle="short"          value="${dateValue}" /></td>

						<td>${item.note}</td>
						<td>INR 0</td>
                        <td>INR ${item.amount}</td>
						<td>INR 0</td>
						<td> ${item.employee.userName}</td>

						<td>
							<form id="form_receipt_suspended_sale" method="get" accept-charset="utf-8" action="${pageContext.request.contextPath}/receipts/paymentreceipt.ps">
							<input type="hidden" value="${item.id}" name="id">
							<input type="submit" class="submit_button float_right" id="submit_receipt" value="Receipt" name="submit">
							</form>
						</td>

					</tr>
            </c:forEach>
             <tr><td colspan="3">Total Order</td><td>${totalOrderAmount}</td> </tr>

                           <tr><td colspan="5">Total Due Amount</td><td>${totalDueAmount}</td> </tr>
                             <tr><td colspan="4">Amount Paid</td><td>${totalPaymentAmount}</td> </tr>
                            <tr><td colspan="2">Final Amount Due</td><td>${totalDueAmount-totalPaymentAmount}</td> </tr>


							</tbody></table>
		</td>
	</tr>
</tbody></table>